<template>
  <div class="content">
    <!-- 广告牌 -->
    <div class="advertising">
      <van-image
        :src="picUrl"
        lazy-load
      ></van-image>
    </div>
    <!-- 新人活动 -->
    <div class="activity">
      <div class="title">
        <span class="activityText">新人专享礼</span>
      </div>
      <div class="main">
        <!-- 左边区域 -->
        <div class="leftArea">
          <h2>新人专享礼包</h2>
          <van-image
            src="//yanxuan.nosdn.127.net/352b0ea9b2d058094956efde167ef852.png"
            lazy-load
          />
        </div>
        <!-- 右边区域 -->
        <div class="rightArea">
          <!-- 福利社 -->
          <div class="module1" v-for="(activity,index) in indexActivityModule" :key="activity.index">
            <div class="caption">
              <div class="topTitle">{{activity.title}}</div>
              <div class="subTitle">{{activity.subTitle}}</div>
              <div :class="{tag:activity.tag !== ''}">{{activity.tag}}</div>
            </div>
            <img
              :src="activity.showPicUrl"
              v-lazy="activity.showPicUrl"
            />
            <div class="discount">
              <div class="line1">{{activity.activityPrice}}</div>
              <div class="line2">{{activity.originPrice}}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 类目热销榜 -->
    <div class="rank">
      <div class="main">
        <div class="title">{{categoryHotSellModule.title}}</div>
        <div class="con">
          <div class="line1">
            <div class="item" v-for="cate1 in categoryList.slice(0,2)" :key="cate1.index">
              <div class="txt">{{cate1.categoryName}}</div>
              <img
                :src="cate1.showPicUrl"
                v-lazy="cate1.showPicUrl"
              />
            </div>
          </div>
          <div class="line2">
            <div class="item" v-for="(cate2,index) in categoryList.slice(2)" :key="cate2.index">
              <div class="txt">{{cate2.categoryName}}</div>
              <img
                :src="cate2.showPicUrl"
                v-lazy="cate2.showPicUrl"
              />
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 特价商品 -->
    <div class="recommendGoods">
      <div class="left">
        <div class="title">{{styleItem.title}}</div>
        <div class="desc">{{styleItem.desc}}</div>
        <div class="picList">
          <img
          v-for="(img,index) in styleItem.picUrlList" :key="img.index"
            :src="img"
            v-lazy="img"
          />
        </div>
      </div>
      <div class="right">
        <div class="title">{{styleBanner.title}}</div>
        <div class="desc">{{styleBanner.desc}}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'Content',
  props:['categoryList'],
  computed:{
    ...mapGetters(['indexData']),
    picUrl(){
      return (((((this.indexData.bigPromotionModule || {}).floorList || [])[0] || {}).cells || [])[0] || {}).picUrl
    },
    indexActivityModule(){
      return this.indexData.indexActivityModule || []
    },
    categoryHotSellModule(){
      return this.indexData.categoryHotSellModule || {}
    },
    styleItem(){
      return (((this.indexData.sceneLightShoppingGuideModule || [])[0]) || {}).styleItem || {}
    },
    styleBanner(){
      return (((this.indexData.sceneLightShoppingGuideModule || [])[1]) || {}).styleBanner || {}
    }
  }
};
</script>

<style lang="less" scoped>
.content {
  .advertising {
    background-color: rgb(247, 180, 135);
    background-image: none;
    background-size: 100% 100%;
    height: 161px;
  }
  .activity {
    background-color: #fff;
    margin-top: 0.2rem;
    margin-bottom: 0.25rem;
    .title {
      height: 45px;
      line-height: 45px;
      text-align: center;
      .activityText {
        position: relative;
        font-size: 20px;
        &::before,
        &::after {
          position: absolute;
          content: '';
          width: 15px;
          height: 3px;
          background: #000;
          top: 10px;
        }
        &::before {
          left: -25px;
        }
        &::after {
          left: 106px;
        }
      }
    }
    .main {
      display: flex;
      padding: 0 0.3rem;
      margin: 10px 0 0 3px;
      height: 230px;
      .leftArea {
        background: #f9e9cf;
        width: 172px;
        height: 217px;
        text-align: center;
        h2 {
          font-size: 15px;
          margin-left: -40px;
        }
        .van-image {
          width: 129px;
          height: 129px;
          margin-top: 10px;
        }
      }
      .rightArea {
        width: 171.5px;
        height: 219px;
        display: flex;
        flex-direction: column;
        margin-left: 2px;
        // margin: 0 auto;
        .module1 {
          background: #fbe2d3;
          width: 171.5px;
          height: 107.5px;
          border-radius: 4px;
          position: relative;
          margin-bottom: 0.04rem;
        }
      }
      .module2 {
        background: #ffecc2;
        width: 171.5px;
        height: 107.5px;
        border-radius: 4px;
        position: relative;
      }
      .caption {
        .topTitle {
          font-size: 16px;
          margin-top: 15px;
          margin-left: 15px;
        }
        .subTitle {
          font-size: 12px;
          color: #7f7f7f;
          margin-left: 13px;
          margin-top: 2px;
        }
      }
      .tag {
        display: inline-block;
        color: #fff;
        font-size: 8px;
        height: 16px;
        text-align: center;
        line-height: 16px;
        border-radius: 2px;
        padding: 0 4px;
        background: #cbb693;
        position: absolute;
        top: 37px;
        left: 15px;
      }
      img {
        width: 100px;
        height: 100px;
        position: absolute;
        top: 0;
        right: 0;
        box-sizing: border-box;
      }
      .discount {
        position: absolute;
        width: 1.066667rem;
        height: 1.066667rem;
        border-radius: 50%;
        background: #f59524;
        padding-top: 0.133333rem;
        color: #fff;
        text-align: center;
        opacity: 0.8;
        top: 0.08rem;
        right: 0.266667rem;
        .line1 {
          font-size: 0.24rem;
        }
        .line2 {
          font-size: 0.2rem;
          text-decoration: line-through;
        }
      }
    }
  }
  .rank {
    margin-bottom: 0.25rem;
    background-color: #fff;
    .title {
        height: 0.9rem;
        line-height: 0.9rem;
        font-size: 16px;
        margin: 5px 0;
      }
    .main {
      padding: 0 0.2rem 0.2rem 0.3rem;
      overflow: hidden;
      .con {
        .line1,
        .line2 {
          display: flex;
        }
        .line1 {
          .item {
            position: relative;
            width: 170px;
            height: 100px;
            border-radius: 0.04rem;
            margin: 0 0.1rem 0.1rem 2px;
            img {
              position: absolute;
              right: 0;
              top: 0;
              width: 100px;
              height: 100px;
            }
            .txt {
              font-size: 14px;
              color: #333;
              position: relative;
              margin-left: 0.3rem;
              margin-top: 0.7rem;
              &::before {
                content: '';
                position: absolute;
                left: 0;
                bottom: -0.18rem;
                width: 25px;
                height: 2px;
                background: #333;
              }
            }
          }
          .item:first-child {
            background: #f9f3e4;
          }
          .item:last-child {
            background: #ebeff6;
          }
        }
        .line2 {
          display: flex;
          flex-wrap: wrap;
          .item {
            display: block;
            width: 82.5px;
            height: 90px;
            background: #f5f5f5;
            border-radius: 0.04rem;
            display: flex;
            flex-direction: column;
            margin: 0 0.15rem 0.12rem 0;
            .txt {
              margin-top: 0.1rem;
              text-align: center;
              font-size: 10px;
              color: #333;
            }
            img {
              width: 60px;
              height: 60px;
              margin: 0 auto;
            }
          }
        }
      }
    }
  }
  .recommendGoods {
    height: 155px;
    display: flex;
    padding: 10px 20px;
    background-color: #fff;
    .left {
      width: 50%;
      height: 132px;
      background-color: #f5f5f5;
      padding: 10px 0 0 10px;
      margin-right: 2px;
      .title {
        font-size: 16px;
      }
      .desc {
        font-size: 12px;
        color: rgb(128, 55, 211);
      }
      .picList {
        box-sizing: border-box;
        img {
          width: 75px;
          height: 75px;
          margin-right: 2px;
        }
      }
    }
    .right {
      width: 50%;
      height: 132px;
      background-color: #f5f5f5;
      background-image: url("https://yanxuan.nosdn.127.net/static-union/1641957082aa912d.png?imageView&thumbnail=343x264");
      background-size: 100% 100%;
      padding: 10px 0 0 15px;
      .title {
        font-size: 16px;
      }
      .desc {
        font-size: 12px;
        color: rgb(255, 179, 102);
      }
    }
  }
}
</style>